package graphics.screens.playlists;

import graphics.Background;
import graphics.screens.mode.OptionScreen;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;

import tool.KeyCode;
import tool.ScreenUtils;
import boot.Boot;

public class PlaylistScreen1 extends OptionScreen implements CommandListener {

	private final Command cancelCommand = new Command("Cancel", Command.EXIT, 1);

	private int index;

	public PlaylistScreen1() {
		addCommand(cancelCommand);
		setCommandListener(this);
	}

	protected void paint(Graphics g) {
		ScreenUtils.setBlackBackground(g);

		Background bg = new Background();
		bg.repaint(g);

		drawMenuEntries(g);
	}

	protected void drawMenuEntries(Graphics g) {

		index = 0;
		int height = g.getFont().getHeight();
		g.setColor(graphics.BootColor.WHITE);

		g.drawString((index + 1) + " - Save current", X_MENU_OFFSET,
				Y_MENU_OFFSET + height * index++, Graphics.LEFT | Graphics.TOP);

		g.drawString((index + 1) + " - Choose", X_MENU_OFFSET, Y_MENU_OFFSET
				+ height * index++, Graphics.LEFT | Graphics.TOP);

	}

	public void commandAction(Command command, Displayable dis) {
		if (command == cancelCommand) {
			Boot.getInstance().readyToGo();
		}
	}

	public void keyPressed(int keyCode) {

		if (keyCode == KeyCode.ONE) {
			Boot.setDisplay(new PlaylistNameScreen());
		} else if (keyCode == KeyCode.TWO) {
			Boot.setDisplay(new PlaylistListScreen());
		}

		repaint();
	}
}
